﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 设计模式.服务定位器模式
{
    public class InitialContext
    {
        public object Lookup(string jndiName)
        {
            if (jndiName.Equals("service1", StringComparison.OrdinalIgnoreCase))
            {
                Console.WriteLine("Looking up and creating a new Service1 object");
                return new Service1();
            }
            else if(jndiName.Equals("service2",StringComparison.OrdinalIgnoreCase))
            {
                Console.WriteLine("Looking up and creating a new Service2 object");
                return new Service2();
            }
            else
            {
                return null;
            }
        }
    }
}
